package com.xinqi.modules.sys.textbook.controller.inner;

import com.xinqi.common.base.response.PageInfo;
import com.xinqi.common.base.response.R;
import com.xinqi.modules.sys.textbook.client.CloudTextbookCatalogClient;
import com.xinqi.modules.sys.textbook.dto.req.CloudTextbookCatalogQueryDTO;
import com.xinqi.modules.sys.textbook.dto.rsp.CloudTextbookCatalogResultDTO;
import com.xinqi.modules.sys.textbook.service.CloudTextbookCatalogService;
import io.swagger.v3.oas.annotations.Hidden;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Primary;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 云课本章节目录内部控制层
 *
 * @author: linkai
 * @date: 2023/04/25
 */
@Hidden
@Primary
@RestController
@RequiredArgsConstructor
public class CloudTextbookCatalogInnerController implements CloudTextbookCatalogClient {
    private final CloudTextbookCatalogService cloudTextbookCatalogService;

    /**
     * 云课本章节目录-分页
     */
    @Override
    public R<PageInfo<CloudTextbookCatalogResultDTO>> page(CloudTextbookCatalogQueryDTO dto) {
        PageInfo<CloudTextbookCatalogResultDTO> page = cloudTextbookCatalogService.page(dto, dto);
        return R.data(page);
    }

    /**
     * 云课本章节目录-详情
     */
    @Override
    public R<CloudTextbookCatalogResultDTO> findById(Long id) {
        CloudTextbookCatalogResultDTO dto = cloudTextbookCatalogService.findById(id);
        return R.data(dto);
    }

    /**
     * 云课本章节目录-树
     */
    @Override
    public R<List<CloudTextbookCatalogResultDTO>> tree(Long textbookId) {
        List<CloudTextbookCatalogResultDTO> list = cloudTextbookCatalogService.tree(textbookId);
        return R.data(list);
    }


    /**
     * 云课本章节目录-列表
     */
    @Override
    public R<List<CloudTextbookCatalogResultDTO>> findByCloudTextbookId(Long textBookId) {
        List<CloudTextbookCatalogResultDTO> dtoList = cloudTextbookCatalogService.findByCloudTextbookId(textBookId);
        return R.data(dtoList);
    }
}
